package com.qzdsoft.erpcloud.controller.act;

import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qzdsoft.erpcloud.controller.BaseController;
import com.qzdsoft.erpcloud.domain.act.CenterSmsLog;
import com.qzdsoft.erpcloud.service.act.CenterCompanyService;
import com.qzdsoft.erpcloud.service.act.CenterSmsLogService;
import com.qzdsoft.erpcloud.service.sys.SysLog;
import com.qzdsoft.erpcloud.vo.query.act.CenterSmsLogInfo;
import com.qzdsoft.erpcloud.vo.query.act.CenterSmsLogQueryParam;
import com.qzdsoft.vo.LayTableResponse;
import com.qzdsoft.vo.Response;

/**
 * Created by Yang
 */
@Controller
@RequestMapping("/act/center/sms/log")
public class CenterSmsLogController extends BaseController{

    @Autowired
    private CenterSmsLogService actCenterSmsLogService;
    @Autowired
    CenterCompanyService actCenterCompanyService;

    /**
     * 页面
     * @param request
     * @param model
     * @return
     */
    @RequestMapping("/index")
    public Object index(HttpServletRequest request, Model model) {
        model.addAttribute("actCenterCompanyMap", actCenterCompanyService.getAllCompany());
        return "act/center_sms/index";
    }


    /**
     * 执行编辑
     *
     * @param request
     * @param actCenterSmsLog
     * @return
     */
//    @ResponseBody
//    @RequestMapping("/edit_execute")
//    public Response<String> editExecute(HttpServletRequest request, CenterSmsLog actCenterSmsLog) {
////        actCenterSmsLog.setCompany_id(SessionUtil.getLoggedCompanyId(request, actCenterSmsLog.getCompany_id()));
//        return actCenterSmsLogService.saveOrUpd(actCenterSmsLog);
//    }
//
//    /**
//     * 删除
//     * @param request
//     * @param id
//     * @return
//     */
//    @ResponseBody
//    @RequestMapping("/del_execute")
//    public Response<String> delExecute(HttpServletRequest request, @RequestParam("id") Integer id) {
//        return actCenterSmsLogService.del(id);
//    }

    /**
     * 查询
     * @param param
     * @return
     */
    @ResponseBody
    @SysLog(description="短信记录查询")
    @RequestMapping("/data")
    public LayTableResponse<CenterSmsLogInfo> data(CenterSmsLogQueryParam param) {
//        Integer companyId = SessionUtil.getLoggedCompanyId(request);
        Integer companyId = param.getCompanyId();
        if(null != companyId){
            param.setCompanyId(companyId);
        }
        return actCenterSmsLogService.selectData(param);
    }

}
